package subraSoft.centaurus.gui.validators.impl;

import org.netbeans.validation.api.Problems;
import org.netbeans.validation.api.Validator;

/**
 * Valida que el campo sea vacio o un long positivo.
 * 
 * @author caeycae
 *
 */
public final class CenPositiveLongValidator implements Validator<String>{

	@Override
	public boolean validate(Problems problems, String compName, String model)
	{
		try
	    {
			if(model != null && !model.isEmpty())
			{
				long l = Long.parseLong(model);
				return l>=0;
			}
	      
	    } catch (NumberFormatException e) {
	      problems.add("El campo " + compName + " debe se un numero positivo");
	      return false;
	    }
	    return true;
	}

}
